﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for DAL_GroupProduct
/// </summary>
public class DAL_GroupProduct
{
    DbProvider data = new DbProvider();

    public DataTable GroupProduct_GetByAll()
    {
        DataTable dt = new DataTable();
        string sql = "select * from GroupProduct Order by [Order]";
        try
        {
            dt = data.ExecuteQuery(sql);
        }
        catch (Exception)
        {

            throw;
        }
        return dt;
    }
    public DataTable GroupProduct_GetByID(string id)
    {
        DataTable dt = new DataTable();
        string sql = string.Format("select * from GroupProduct where [Id] = {0}", id);
        try
        {
            dt = data.ExecuteQuery(sql);
        }
        catch (Exception)
        {

            throw;
        }
        return dt;
    }

    public DataTable GroupProduct_GetByTop(int top, string where, string order)
    {
        DataTable dt = new DataTable();
        string sql = "";
        if (top <= 0)
        {
            sql += "SELECT * FROM GroupProduct";
        }
        else
        {
            sql += "SELECT TOP " + top + " * FROM GroupProduct";
        }
        if (where != "")
        {
            sql += " WHERE " + where;
        }
        if (order != "")
        {
            sql += " Order by " + order;
        }
        try
        {
            dt = data.ExecuteQuery(sql);

        }
        catch (Exception)
        {

            throw;
        }
        return dt;
    }
}